package Tread_and_Runnable;

/**
 * 创建三个窗口，总票数100张
 * @author luyao_start
 * @create 2021-08-15-19:00
 */
class Window implements Runnable{
    private int ticket = 100;

    @Override
    public void run() {
        while(true){
            if(ticket > 0){
                System.out.println(Thread.currentThread().getName()+":卖票，票号为"+ticket);
                ticket--;
            }else {
                break;
            }
        }
    }


}

public class WindowTEST {
    public static void main(String[] args) {
        Window ticket = new Window();
        Thread t1 = new Thread(ticket, "啊");
        Thread t2 = new Thread(ticket, "吧");
        Thread t3 = new Thread(ticket, "从");

        t1.start();
        t2.start();
        t3.start();
    }
}
